home *** CD-ROM | disk | FTP | other *** search
/ JCSM Shareware Collection 1996 September / JCSM Shareware Collection (JCS Distribution) (September 1996).ISO / prgtools / euphor13.zip / LIBRARY.DOC < prev    next >
Text File  |  1995-05-28  |  78KB  |  2,117 lines

  1.  
  2.             Part II - Library Routines
  3.  
  4.  1. Introduction
  5.  
  6.  A large number of library routines are provided. Some are built right into
  7.  the interpreter, ex.exe. Others are written in Euphoria and you must include
  8.  one of the .e files in euphoria\include to use them. Where this is the case, 
  9.  the appropriate include file is noted in the "Syntax" part of the description.
  10.  Of course an include file need only be included once in your program. The 
  11.  editor displays in magenta those routines that are built into the interpreter,
  12.  ex.exe, and require no include file. You can override the definition of these
  13.  built-in routines by defining your own routine with the same name. You will 
  14.  get a suppressible warning if you do this.
  15.  
  16.  To indicate what kind of object may be passed in and returned, the following 
  17.  prefixes are used:
  18.  
  19.    x - a general object (atom or sequence)
  20.    s - a sequence
  21.    a - an atom
  22.    i - an integer 
  23.   fn - an integer used as a file number
  24.   st - a string sequence, or single-character atom
  25.  
  26.  An error will result if an illegal argument value is passed to any of these 
  27.  routines.
  28.  
  29.  
  30.  2. Routines by Application Area
  31.  
  32.  2.1  Predefined Types         
  33.       
  34.       As well as declaring variables with these types, you can also call them 
  35.       just like ordinary functions, in order to test if a value is a certain 
  36.       type.
  37.  
  38.       integer     - test if an object is an integer
  39.       atom        - test if an object is an atom 
  40.       sequence     - test if an object is a sequence
  41.       
  42.  2.2  Sequence Manipulation   
  43.     
  44.       length     - return the length of a sequence
  45.       repeat     - repeat an object n times to form a sequence of length n
  46.       append     - add a new element to the end of a sequence
  47.       prepend     - add a new element to the beginning of a sequence
  48.       
  49.  2.3  Searching and Sorting  
  50.  
  51.       compare     - compare two objects
  52.       find        - find an object in a sequence
  53.       match       - find a sequence as a slice of another sequence
  54.       sort        - sort the elements of a sequence into ascending order
  55.  
  56.  2.4  Pattern Matching
  57.       
  58.       lower     - convert a string to lower case
  59.       upper     - convert a string to upper case
  60.       wildcard_match - match a pattern containing ? and * wildcards
  61.       wildcard_file  - match a file name against a wild card specification
  62.  
  63.  2.5  Math            
  64.  
  65.       These routines can be applied to individual atoms or to sequences of 
  66.       values. See "Arithmetic Operations on Sequences" in chapter 2 of the
  67.       reference manual.
  68.       
  69.       sqrt    - calculate the square root of an object
  70.       rand    - generate random numbers
  71.       sin    - calculate the sine of an angle
  72.       cos    - calculate the cosine of an angle
  73.       tan    - calculate the tangent of an angle
  74.       log    - calculate the natural logarithm 
  75.       floor    - round down to the nearest integer
  76.       remainder    - calculate the remainder when a number is divided by another
  77.       power    - calculate a number raised to a power
  78.  
  79.  
  80.  2.6  File and Device I/O 
  81.  
  82.       To do input or output on a file or device you must first open the file
  83.       or device, then use the routines below to read or write to it, then close 
  84.       the file or device. open() will give you a file number to use as the 
  85.       first argument of the other I/O routines. Certain files/devices are 
  86.       opened for you automatically (as text files):
  87.  
  88.          0 - standard input
  89.          1 - standard output
  90.          2 - standard error
  91.  
  92.       Unless you redirect them on the command line, standard input comes from 
  93.       the keyboard, standard output and standard error go to the screen. When 
  94.       you write something to the screen it is written immediately without 
  95.       buffering. If you write to a file, your characters are put into a buffer 
  96.       until there are enough of them to write out efficiently. When you close 
  97.       the file or device, any remaining characters are written out. Input from
  98.       files is also buffered. When your program terminates, any files that are
  99.       still open will be closed for you automatically.
  100.       
  101.       Note: If a program (written in Euphoria or any other language) has a 
  102.       file open for writing, and you are forced to reboot your computer for 
  103.       any reason, then you should immediately run CHKDSK or SCANDISK to 
  104.       repair any damage to the file system that may have occurred.
  105.  
  106.       open    - open a file or device
  107.       close    - close a file or device
  108.       print    - print a Euphoria object with {,,} to show the structure
  109.       ? x    - shorthand for print(1, x)
  110.       printf    - formatted print to a file or device
  111.       sprintf   - formatted print returned as a string sequence
  112.       puts    - output a string sequence to a file or device
  113.       getc    - read the next character from a file or device
  114.       gets    - read the next line from a file or device
  115.       get_key    - check for key pressed by the user, don't wait
  116.       wait_key  - wait for user to press a key
  117.       get    - read the representation of any Euphoria object from a file
  118.       value    - read the representation of any Euphoria object from a string
  119.       seek    - move to any character position within an open file
  120.       where    - report the current character position in an open file
  121.       current_dir - return the name of the current directory
  122.       dir    - return complete info on all files in a directory
  123.       
  124.  2.7  Mouse Support   
  125.  
  126.       get_mouse        - return mouse "events" (clicks, movements)
  127.       mouse_events  - select mouse events to watch for
  128.       mouse_pointer - display or hide the mouse pointer
  129.  
  130.  2.8  Operating System 
  131.  
  132.       time    - number of seconds since a fixed point in the past
  133.       date    - current year, month, day, hour, minute, second etc.
  134.       command_line - DOS command-line used to run this program
  135.       getenv    - get value of an environment variable
  136.       system    - execute a DOS command line
  137.       abort    - terminate execution
  138.       
  139.  2.9 Special Machine-dependent routines
  140.       
  141.       machine_func - specialized operations in ex.exe with return value
  142.       machine_proc - specialized operations in ex.exe - no return value
  143.       
  144.  2.10 Debugging
  145.  
  146.       trace    - dynamically turns tracing on or off
  147.  
  148.  2.11 Graphics & Sound
  149.   
  150.       clear_screen - clear the screen - text or graphics
  151.       position       - set cursor line and column
  152.       get_position - return cursor line and column
  153.       graphics_mode - select a new graphics (or text) mode
  154.       video_config - return parameters of current graphics mode
  155.       scroll       - scroll text screen up or down
  156.       wrap       - control line wrap at right edge of screen
  157.       cursor       - select cursor shape
  158.       text_color   - set foreground text color
  159.       bk_color       - set background color for text and graphics
  160.       palette       - change color for one color number
  161.       all_palette  - change color for all color numbers
  162.       text_rows       - set number of lines on text screen
  163.       pixel       - set color of a pixel or set of pixels
  164.       get_pixel       - read color of a pixel or set of pixels
  165.       draw_line    - connect a series of graphics points with a line
  166.       polygon       - draw an n-sided figure
  167.       ellipse       - draw an ellipse (circle)
  168.       sound       - make a sound on the PC speaker
  169.       read_bitmap  - read a bitmap file and return a sequence of pixels
  170.       save_image   - save a rectangular region from a graphics screen
  171.       save_text_image - save a rectangular region from a text screen
  172.       display_image - display an image on the graphics screen
  173.       display_text_image - display an image on the text screen
  174.       get_active_page - return the page currently being written to
  175.       set_active_page - change the page currently being written to    
  176.       get_display_page - return the page currently being displayed
  177.       set_display_page - change the page currently being displayed
  178.  
  179.  2.12 Machine Level Interface 
  180.  
  181.       With this low-level machine interface you can read and write to memory.
  182.       You can also set up your own 386+ machine language routines and call 
  183.       them. The usual guarantee that Euphoria will protect you from machine-
  184.       level errors does *not* apply when you use these routines. There are 
  185.       only some simple checks to catch the use of memory addresses that are 
  186.       negative or zero. (Theoretically address 0 is acceptable, but in 
  187.       practice it is usually an error so we catch it.) If you do happen to
  188.       reference a bad address, it will likely be caught by DOS4GW and you'll
  189.       see an error message with a dump of register values.
  190.  
  191.       Most Euphoria programmers will never use this interface, but it is 
  192.       important because it makes it possible to get into every nook and cranny  
  193.       of the hardware and operating system. For those with very specialized
  194.       applications this could be crucial. 
  195.  
  196.       Machine code routines can be written by hand, or taken from the 
  197.       disassembled output of a compiler for C or some other language. 
  198.       Remember that your machine code will be running in 32-bit protected 
  199.       mode. See demo\callmach.ex for an example.
  200.  
  201.       peek     - read a byte from memory
  202.       poke    - write a byte to memory
  203.       call    - call a machine language routine
  204.       allocate    - allocate a block of memory
  205.       free    - deallocate a block of memory
  206.       int_to_bytes - convert an integer to 4 bytes
  207.       bytes_to_int - convert 4 bytes to an integer
  208.       int_to_bits - convert an integer to a sequence of bits
  209.       bits_to_int - convert a sequence of bits to an integer
  210.  
  211.  
  212.      
  213.      
  214.  3. Alphabetical Listing of all Routines
  215.              
  216.              
  217.  
  218. ──────────────────────────────────────<?>───────────────────────────────────────
  219.  
  220.  Syntax:      ? x    
  221.  
  222.  Description: This is just a shorthand way of saying:  print(1, x)
  223.            i.e. printing the value of an expression to the standard output. 
  224.           
  225.  Example: 
  226.           ? {1, 2} + {3, 4}  
  227.           
  228.           would display {4, 6}. 
  229.  
  230.  Comments:    ? differs slightly from print() since it will add new-lines to 
  231.            make the output more readable on your screen or wherever you 
  232.            have directed standard output.  
  233.  
  234.  See Also:    print
  235.  
  236. ────────────────────────────────────<abort>─────────────────────────────────────
  237.  
  238.  Syntax:      abort(a)       
  239.     
  240.  Description: Abort execution of the program. The argument a is an integer 
  241.            status value to be returned to the operating system. A value of 0
  242.            generally indicates successful completion of the program. Other 
  243.            values can indicate various kinds of errors. Euphoria for MS-DOS
  244.            currently ignores this argument and always returns 0. 
  245.            
  246.  Comments:    abort() is useful when a program is many levels deep in 
  247.            subroutine calls, and execution must end immediately, perhaps
  248.            due to a severe error that has been detected.
  249.  
  250.  Example:     
  251.            if x = 0 then
  252.                puts(ERR, "can't divide by 0 !!!\n")
  253.                abort(1)
  254.            else
  255.                z = y / x
  256.            end if
  257.  
  258. ─────────────────────────────────<all_palette>──────────────────────────────────
  259.  
  260.  Syntax:      include graphics.e
  261.           all_palette(s)
  262.       
  263.  Description: Specify new color intensities for the entire set of colors in the
  264.            current graphics mode. s is a sequence of the form:
  265.                
  266.                {{r,g,b}, {r,g,b}, ... {r,g,b}}
  267.            
  268.            Each element specifies a new color intensity {red, green, blue}
  269.            for the corresponding color number, starting with color number 0.
  270.           The values for red, green and blue must be in the range 0 to 63.
  271.           
  272.  Comments:    This executes much faster than if you were to use palette() to 
  273.            set the new color intensities one by one. This procedure can
  274.            be used with read_bitmap() to quickly display a picture on the
  275.            screen.
  276.            
  277.  Example Program: demo\bitmap.ex
  278.  
  279.  See Also:    palette, read_bitmap, video_config, graphics_mode           
  280.            
  281. ───────────────────────────────────<allocate>───────────────────────────────────
  282.  
  283.  Syntax:      include machine.e
  284.            a = allocate(i)
  285.     
  286.  Description: Allocate i contiguous bytes of memory. Return the address of the
  287.           block of memory, or return 0 if the memory can't be allocated.
  288.           
  289.  Example:  
  290.            buffer = allocate(100)
  291.            for i = 0 to 99 do
  292.                  poke(buffer+i, 0)
  293.            end for
  294.  
  295.  See Also:    free, peek, poke
  296.  
  297. ────────────────────────────────────<append>────────────────────────────────────
  298.  
  299.  Syntax:      s2 = append(s1, x)
  300.     
  301.  Description: Create a sequence identical to s1 but with x added on the end
  302.            as the last element. The length of s2 will be length(s1) + 1. 
  303.           
  304.  Comments:    If x is an atom this is equivalent to s2 = s1 & x. If x is a 
  305.            sequence it is not equivalent. 
  306.           
  307.           The extra storage is allocated automatically and very 
  308.           efficiently with Euphoria's dynamic storage allocation. 
  309.           The case where s1 and s2 are the same variable (as below) 
  310.           is highly optimized.
  311.           
  312.  Example 1:   You can use append to dynamically grow a sequence e.g.
  313.     
  314.         x = {}
  315.         for i = 1 to 10 do
  316.             x = append(x, i)
  317.         end for
  318.         -- x is now {1,2,3,4,5,6,7,8,9,10}
  319.  Example 2:
  320.            x = {"fred", "barney"}
  321.            x = append(x, "wilma")
  322.            
  323.            -- x is now {"fred", "barney", "wilma"}
  324.  
  325.  See Also:    prepend, concatenation (&) operator in refman.doc
  326.  
  327. ─────────────────────────────────────<atom>─────────────────────────────────────
  328.  
  329.  Syntax:      i = atom(x)
  330.     
  331.  Description: Return 1 if x is an atom else return 0.
  332.  
  333.  Comments:    This serves to define the atom type. You can also call it
  334.           like an ordinary function to determine if an object is an
  335.           atom.
  336.          
  337.  Example 1:
  338.            atom a
  339.            a = 5.99
  340.            
  341.  Example 2:
  342.            line = gets(0)
  343.            if atom(line) then
  344.                 puts(SCREEN, "end of file\n")
  345.            end if
  346.           
  347.  See Also:    sequence
  348.  
  349. ─────────────────────────────────<bits_to_int>──────────────────────────────────
  350.  
  351.  Syntax:      include machine.e
  352.            a = bits_to_int(s)
  353.            
  354.  Description: Convert a sequence of binary 1's and 0's into a positive
  355.             number. The least-significant bit is s[1].
  356.             
  357.  Comments:    If you print s the bits will appear in "reverse" order, but
  358.            it is convenient to have increasing subscripts access bits of 
  359.            increasing significance.
  360.            
  361.  Example:     a = bits_to_int({1,1,1,0,1})
  362.            -- a is 23 (binary 10111)
  363.  
  364.  See Also:    int_to_bits, and/or/not of sequences in refman.doc
  365.             
  366. ───────────────────────────────────<bk_color>───────────────────────────────────
  367.  Syntax:      include graphics.e 
  368.            bk_color(i)
  369.     
  370.  Description: Set the background color. In graphics modes the whole screen is
  371.           affected immediately. In text modes any new characters that you 
  372.           print will have the new background color.
  373.  
  374.  Comments:    The various colors are defined as constants in graphics.e
  375.  
  376.  Example:     bk_color(BLACK)
  377.  
  378.  See Also:    text_color
  379.  
  380. ─────────────────────────────────────<call>─────────────────────────────────────
  381.  
  382.  Syntax:      call(a)
  383.     
  384.  Description: Call a machine language routine that starts at address a. This
  385.           routine must execute a RET instruction #C3 to return control
  386.           to Euphoria. The routine should save and restore any registers 
  387.           that it uses. 
  388.           
  389.  Comments:    You can allocate a block of memory for the routine and then poke
  390.             in the bytes of machine code. You might allocate other blocks of
  391.             memory for data and parameters that the machine code can operate
  392.             on. The addresses of these blocks could be poked into the 
  393.             machine code. 
  394.  
  395.  Example Program: see demo\callmach.ex
  396.  
  397.  See Also:    allocate, free, peek, poke
  398.  
  399. ─────────────────────────────────<clear_screen>─────────────────────────────────
  400.  
  401.  Syntax:      clear_screen()
  402.     
  403.  Description: Clear the screen using the current background color (may be set 
  404.            by bk_color()). 
  405.  
  406.  Comments:    This works in all text and graphics modes.
  407.  
  408.  See Also:    bk_color, graphics_mode
  409.  
  410. ────────────────────────────────────<close>─────────────────────────────────────
  411.  
  412.  Syntax:      close(fn)
  413.     
  414.  Description: Close a file or device and flush out any still-buffered 
  415.            characters.
  416.  
  417.  Comments:    Any still-open files will be closed automatically when your 
  418.            program terminates.
  419.            
  420.  See Also:    open
  421.  
  422. ────────────────────────────────<command_line>──────────────────────────────────
  423.  
  424.  Syntax:      s = command_line() 
  425.  
  426.  Description: Return a sequence of strings, where each string is a word from 
  427.            the ex command line that started Euphoria. The first word will
  428.            be the path to the Euphoria executable. The next word is the 
  429.            name of your Euphoria .ex file. After that will come any extra
  430.            words typed by the user. You can use these words in your 
  431.            program. 
  432.  
  433.  Comments:    Euphoria (ex.exe) does not use any command line options. You
  434.            can use any options for your own program.
  435.  
  436.  Example:
  437.            -- the user types:  ex myprog myfile.dat 12345
  438.            
  439.            cmd = command_line()
  440.            
  441.            -- cmd will be:  {"C:\EUPHORIA\BIN\EX.EXE", 
  442.                        "myprog",
  443.                        "myfile.dat",
  444.                        "12345"}
  445.  
  446.  See Also:    getenv
  447.  
  448. ───────────────────────────────────<compare>────────────────────────────────────
  449.  
  450.  Syntax:      i = compare(x1, x2)
  451.     
  452.  Description: Return 0 if objects x1 and x2 are identical, 1 if x1 is greater 
  453.           than x2, -1 if x1 is less than x2. Atoms are considered to be 
  454.           less than sequences. Sequences are compared "alphabetically" 
  455.           starting with the first element until a difference is found. 
  456.           
  457.  Example 1:   x = compare({1,2,{3,{4}},5}, {2-1,1+1,{3,{4}},6-1})
  458.            -- identical, x is 0
  459.                
  460.  Example 2:   if compare("ABC", "ABCD") < 0 then   -- -1
  461.          -- will be true: ABC is "less" because it is shorter
  462.            end if
  463.  
  464.  See Also:    equals (=) operator in refman.doc
  465.  
  466. ─────────────────────────────────────<cos>──────────────────────────────────────
  467.  
  468.  Syntax:      x2 = cos(x1)
  469.     
  470.  Description: Return the cosine of x1, where x1 is in radians.
  471.  
  472.  Comments:    This function may be applied to an atom or to all elements
  473.            of a sequence.
  474.  
  475.  Example:     x = cos({.5, .6, .7})
  476.            
  477.            -- x is {0.8775826, 0.8253356, 0.7648422}
  478.  
  479.  See Also:    sin, tan, log, sqrt
  480.  
  481. ─────────────────────────────────<current_dir>──────────────────────────────────
  482.  
  483.  Syntax:      include file.e
  484.            s = current_dir()
  485.     
  486.  Description: Return the name of the current working directory.
  487.  
  488.  Example:
  489.            sequence s
  490.            s = current_dir()
  491.            -- s would have "C:\EUPHORIA\DOC" if you were in that directory
  492.            
  493.  See Also:    dir, getenv
  494.  
  495. ────────────────────────────────────<cursor>────────────────────────────────────
  496.  
  497.  Syntax:      include graphics.e  
  498.            cursor(i)
  499.     
  500.  Description: Select a style of cursor. graphics.e contains:
  501.         
  502.         global constant NO_CURSOR = 8192,
  503.              UNDERLINE_CURSOR  = 1543,
  504.              BLOCK_CURSOR      = 7,
  505.              HALF_BLOCK_CURSOR = 1031
  506.  
  507.  Example:     cursor(BLOCK_CURSOR)
  508.  
  509. ─────────────────────────────────────<date>─────────────────────────────────────
  510.  
  511.  Syntax:      s = date()
  512.     
  513.  Description: Return a sequence with the following information:
  514.          { year (since 1900),
  515.            month (January = 1),
  516.            day (day of month, starting at 1),
  517.            hour (0 to 23),
  518.            minute (0 to 59),
  519.            second (0 to 59),
  520.            day of the week (Sunday = 1),
  521.            day of the year (January 1st = 1) }
  522.  
  523.  Example:     now = date()
  524.            -- now has: {95,3,24,23,47,38,6,83}
  525.            -- i.e. Friday March 24, 1995 at 11:47:38pm, day 83 of the year
  526.  
  527.  See Also:    time
  528.  
  529. ─────────────────────────────────────<dir>──────────────────────────────────────
  530.  
  531.  Syntax:      include file.e
  532.            x = dir(st)
  533.     
  534.  Description: Return directory information for the file or directory named by
  535.             st. If there is no file or directory with this name then -1 is
  536.             returned.
  537.             
  538.            This information is similar to what you would get from the DOS
  539.            DIR command. A sequence is returned where each element is a 
  540.            sequence that describes one file or subdirectory. 
  541.           
  542.           If st names a directory you may have entries for "." and "..",
  543.           just as with the DOS DIR command. If st names a file then x will
  544.           have just one entry, i.e. length(x) will be 1. 
  545.           
  546.           Each entry contains the name, attributes and file size as well 
  547.           as the year, month, day, hour, minute and second of the last 
  548.           modification. You can refer to the elements of an entry with 
  549.           the following constants defined in file.e:
  550.         
  551.         global constant 
  552.             D_NAME = 1,
  553.             D_ATTRIBUTES = 2,
  554.             D_SIZE = 3,
  555.  
  556.             D_YEAR = 4,
  557.             D_MONTH = 5,
  558.             D_DAY = 6,
  559.  
  560.             D_HOUR = 7,
  561.             D_MINUTE = 8,
  562.             D_SECOND = 9
  563.           
  564.           The attributes element is a string sequence containing 
  565.           characters chosen from:
  566.  
  567.             d - directory
  568.             r - read only file
  569.             h - hidden file
  570.             s - system file
  571.             v - volume-id entry
  572.             a - archive file
  573.  
  574.           A normal file without special attributes would just have an empty
  575.           string, "", in this field. 
  576.         
  577.  Comments:    The top level directory, e.g. c:\ does not have "." or ".."
  578.           entries. 
  579.           
  580.           This function is often used just to test if a file or 
  581.           directory exists.
  582.           
  583.  Example:      
  584.           d = dir(current_dir()) 
  585.           
  586.           -- d might have:
  587.         {
  588.              {".",    "d",     0  1994, 1, 18,  9, 30, 02},
  589.              {"..",   "d",     0  1994, 1, 18,  9, 20, 14},
  590.              {"fred", "ra", 2350, 1994, 1, 22, 17, 22, 40},
  591.              {"sub",  "d" ,    0, 1993, 9, 20,  8, 50, 12}
  592.         } 
  593.           
  594.           d[3][D_NAME] would be "fred"
  595.           
  596.  Example Programs: bin\search.ex, install.ex
  597.  
  598.  See Also: wildcard_file
  599.  
  600. ────────────────────────────────<display_image>─────────────────────────────────
  601.  
  602.  Syntax:      include image.e
  603.            display_image(s1, s2)
  604.            
  605.  Description: Display at point s1 on the screen the 2-d sequence of pixels 
  606.            contained in s2. s1 is a two-element sequence {x, y}. s2 is a 
  607.            sequence of sequences, where each sequence is one horizontal 
  608.            line of pixel colors to be displayed. The first pixel of the 
  609.            first sequence is displayed at s1. It is the top-left pixel. 
  610.            All other pixels appear to the right or below of this point.
  611.  
  612.  Comments:    s2 might be the result of a previous call to save_image(), or
  613.            read_bitmap(), or it could be something you have created.
  614.           
  615.           You could use save_image/display_image in a graphical user 
  616.           interface, to allow "pop-up" dialog boxes, and drop-down menus
  617.           to appear and disappear without losing what was previously on 
  618.           the screen.
  619.           
  620.           The sequences (rows) of the image do not have to all be the
  621.           same length.
  622.           
  623.  Example:     display_image({20,30}, {{1,5,9}, 
  624.                        {2,4}, 
  625.                        {1,0,1,0,4}, 
  626.                        {5,5,5}})
  627.            -- displays a small 4-line image at {20,30}, with the pixels
  628.               appearing in the same relative positions as the layout
  629.               above would indicate
  630.  
  631.  Example Program: see demo\bitmap.ex
  632.  
  633.  See Also:    save_image, read_bitmap, display_text_image
  634.  
  635. ─────────────────────────────<display_text_image>───────────────────────────────
  636.  
  637.  Syntax:      include image.e
  638.            display_text_image(s1, s2)
  639.  
  640.  Description: Display the 2-d sequence of characters and attributes contained
  641.             in s2 at line s1[1], column s1[2]. s2 is a sequence of sequences,
  642.             where each sequence is a string of characters and attributes to 
  643.             be displayed. The top-left character is displayed at s1. Other 
  644.             characters appear to the right or below of this position. The
  645.             attributes indicate the foreground and background color of the 
  646.             preceding character.
  647.             
  648.  Comments:    s2 would normally be the result of a previous call to 
  649.            save_text_image(), although you could construct it yourself.
  650.           
  651.           This routine only works in text modes.
  652.           
  653.           You might use save_text_image/display_text_image in a text-mode
  654.           graphical user interface, to allow "pop-up" dialog boxes, and 
  655.           drop-down menus to appear and disappear without losing what was
  656.           previously on the screen.
  657.  
  658.            The sequences of the text image do not have to all be the same
  659.            length.
  660.            
  661.  Example:     clear_screen()
  662.            display_text_image({1,1}, {{'A', WHITE, 'B', GREEN},
  663.                        {'C', RED+16*WHITE},
  664.                        {'D', BLUE}})
  665.            -- displays:  AB
  666.                      C
  667.                      D
  668.              in the appropriate colors at the top left corner of the screen
  669.  
  670.  See Also:    save_text_image, display_image
  671.  
  672. ──────────────────────────────────<draw_line>───────────────────────────────────
  673.  
  674.  Syntax:      include graphics.e
  675.            draw_line(i, s)
  676.     
  677.  Description: Draw a line connecting two or more points in s, using color i. 
  678.  
  679.  Example:     draw_line(WHITE, {{100, 100}, {200, 200}, {900, 700}}) 
  680.  
  681.           This would connect the three points in the sequence using a white
  682.           line, i.e. a line would be drawn from {100, 100} to {200, 200} 
  683.           and another line would be drawn from {200, 200} to {900, 700}.
  684.  
  685.  See Also:    polygon, ellipse, pixel
  686.  
  687. ───────────────────────────────────<ellipse>────────────────────────────────────
  688.  
  689.  Syntax:      include graphics.e
  690.            ellipse(i1, i2, s1, s2)
  691.     
  692.  Description: Draw an ellipse with color i1. The ellipse will neatly fit inside
  693.           the rectangle defined by diagonal points s1 {x1, y1} and s2 
  694.           {x2, y2}. If the rectangle is a square then the ellipse will be a
  695.           circle. Fill the ellipse when i2 is 1. Don't fill when i2 is 0. 
  696.  
  697.  Example:     ellipse(MAGENTA, 0, {10, 10}, {20, 20})
  698.  
  699.           This would make a magenta colored circle just fitting inside the
  700.           square: {10, 10}, {10, 20}, {20, 20}, {20, 10}.
  701.  
  702.  Example Program: demo\sb.ex
  703.  
  704.  See Also:    polygon, draw_line
  705.  
  706. ─────────────────────────────────────<find>─────────────────────────────────────
  707.  
  708.  Syntax:      i = find(x, s)
  709.  
  710.  Description: Find x as an element of s. If successful, return the index 
  711.            of the first element of s that matches. If unsuccessful 
  712.            return 0. 
  713.     
  714.  Example 1:   location = find(11, {5, 8, 11, 2, 3})
  715.           -- location is set to 3
  716.  
  717.  Example 2:   names = {"fred", "rob", "george", "mary", ""}
  718.           location = find("mary", names)
  719.           -- location is set to 4
  720.  
  721.  See Also:    match, compare
  722.  
  723. ────────────────────────────────────<floor>─────────────────────────────────────
  724.  
  725.  Syntax:      x2 = floor(x1)
  726.     
  727.  Description: Return the greatest integer less than or equal to x1.
  728.  
  729.  Comments:    This function may be applied to an atom or to all elements
  730.            of a sequence.
  731.            
  732.  Example:     y = floor({0.5, -1.6, 9.99, 100})
  733.            -- y is {0, -2, 9, 100}
  734.  
  735.  See Also:    remainder
  736.  
  737. ─────────────────────────────────────<free>─────────────────────────────────────
  738.  
  739.  Syntax:      include machine.e
  740.            free(a)
  741.     
  742.  Description: Free up a previously allocated block of memory by specifying the
  743.           address of the start of the block, i.e. the address that was
  744.           returned by allocate(). 
  745.  
  746.  Comments:    Use free() to recycle blocks of memory during execution. This
  747.             will reduce the chance of running out of memory or getting into 
  748.             excessive virtual memory swapping to disk. Do not reference 
  749.             a block of memory that has been freed. When your program 
  750.             terminates, all allocated memory will be returned to the system. 
  751.            
  752.  Example Program: demo\callmach.ex
  753.  
  754.  See Also:    allocate
  755.  
  756. ─────────────────────────────────────<get>──────────────────────────────────────
  757.  
  758.  Syntax:      include get.e
  759.            s = get(fn)
  760.  
  761.  Description: Read the next representation of a Euphoria object from file fn, 
  762.            and convert it into the value of that object. s will be a 
  763.            2-element sequence {error status, value}. Error status values 
  764.            are:
  765.  
  766.         GET_SUCCESS  -- object was read successfully
  767.         GET_EOF      -- end of file before object was read
  768.         GET_FAIL     -- object is not syntactically correct
  769.  
  770.           get() can read arbitrarily complicated Euphoria objects. You 
  771.           could have a long sequence of values in braces and separated by 
  772.           commas, e.g. {23, {49, 57}, 0.5, -1, 99, 'A', "john"}. A single
  773.           call to get() will read in this entire sequence and return it's
  774.           value as a result. 
  775.     
  776.           Each call to get() picks up where the previous call left off. For 
  777.           instance, a series of 5 calls to get() would be needed to read 
  778.           in: 
  779.     
  780.         99 5.2 {1,2,3} "Hello" -1
  781.  
  782.            Separate the objects with one or more "whitespace" characters
  783.            (blank, tab or \n).
  784.            
  785.  Comments:    The combination of print() and get() can be used to save any 
  786.            Euphoria object to disk and later read it back. This technique
  787.            could be used to implement a database as one or more large 
  788.            Euphoria sequences stored in disk files. The sequences could be
  789.            read into memory, updated and then written back to disk after
  790.            each series of transactions is complete. 
  791.  
  792.  Example:     Suppose your program asks the user to enter a number from the
  793.             keyboard. If he types 77.5, get(0) would return:
  794.                  
  795.                  {GET_SUCCESS, 77.5} 
  796.             
  797.             whereas gets(0) would return
  798.               
  799.               "77.5\n". 
  800.  
  801.  Example Program: see demo\mydata.ex. 
  802.  
  803.  See Also:    print, value, gets, getc
  804.  
  805. ───────────────────────────────<get_active_page>────────────────────────────────
  806.  
  807.  Syntax:      include image.e
  808.            i = get_active_page()
  809.  
  810.  Description: Some graphics modes on most video cards have multiple pages
  811.            of memory. This lets you write screen output to one page
  812.            while displaying a different page. get_active_page() returns
  813.            the current page number that screen output is being sent to.
  814.            
  815.  Comments:    The active and display pages are both 0 by default.
  816.           
  817.           video_config() will tell you how many pages are available in
  818.           the current graphics mode.
  819.  
  820.  See Also:    set_active_page, get_display_page, video_config
  821.  
  822. ───────────────────────────────<get_display_page>───────────────────────────────
  823.  
  824.  Syntax:      include image.e
  825.            i = get_display_page()
  826.  
  827.  Description: Some graphics modes on most video cards have multiple pages
  828.            of memory. This lets you write screen output to one page
  829.            while displaying another. get_display_page() returns the current
  830.            page number that is being displayed on the monitor.
  831.            
  832.  Comments:    The active and display pages are both 0 by default.
  833.  
  834.           video_config() will tell you how many pages are available in
  835.           the current graphics mode.
  836.  
  837.  See Also:    set_display_page, get_active_page, video_config
  838.  
  839. ───────────────────────────────────<get_key>────────────────────────────────────
  840.  
  841.  Syntax:      i = get_key()
  842.     
  843.  Description: Return the key that was pressed by the user, without waiting for 
  844.           carriage return. Return -1 if no key was pressed. Special
  845.           codes are returned for the function keys, arrow keys etc.
  846.  
  847.  Comments:    DOS can hold a small number of key-hits in its keyboard buffer. 
  848.            get_key will return the next one from the buffer, or -1 if 
  849.            the buffer is empty.
  850.  
  851.  See Also:    wait_key, getc
  852.  
  853. ──────────────────────────────────<get_mouse>───────────────────────────────────
  854.  
  855.  Syntax:      include mouse.e
  856.            x = get_mouse()
  857.     
  858.  Description: Return the last mouse event in the form:
  859.           
  860.           {event, x, y} 
  861.             
  862.             or return -1 if there has not been a mouse event since the last
  863.             time get_mouse() was called. 
  864.  
  865.           Constants have been defined in mouse.e for the possible mouse
  866.           events: 
  867.     
  868.             global constant MOVE = 1,  
  869.                     LEFT_DOWN = 2,
  870.                     LEFT_UP = 4,
  871.                     RIGHT_DOWN = 8,
  872.                     RIGHT_UP = 16,
  873.                     MIDDLE_DOWN = 32,
  874.                     MIDDLE_UP = 64
  875.     
  876.           x and y are the coordinates of the mouse pointer at the time that 
  877.           the event occurred. get_mouse() returns immediately with either 
  878.           a -1 or a mouse event. It does not wait for an event to occur. 
  879.           You must check it frequently enough to avoid missing an event.
  880.           When the next event occurs, the current event will be lost, if 
  881.           you haven't read it. In practice it is not hard to catch almost
  882.           all events, and the ones that are lost are usually lost at a 
  883.           lower level in the system, beyond the control of your program.
  884.           Losing a MOVE event is generally not too serious, as the next 
  885.           MOVE will tell you where the mouse pointer is. 
  886.  
  887.  Comments:    You need a DOS mouse driver to use this routine.
  888.   
  889.            You can use get_mouse() in most text and graphics modes. 
  890.           Unfortunately, DOS does not support the use of a mouse
  891.           in SVGA graphics modes (beyond 640x480 pixels).
  892.  
  893.  Example:     a return value of:
  894.          
  895.          {2, 100, 50} 
  896.            
  897.            would indicate that the left button was pressed down while the
  898.            mouse pointer was at position x=100, y=50 on the screen.     
  899.  
  900.  See Also:    mouse_events, mouse_pointer
  901.  
  902. ──────────────────────────────────<get_pixel>───────────────────────────────────
  903.  
  904.  Syntax:      include graphics.e
  905.            x = get_pixel(s)
  906.     
  907.  Description: When s is a 2-element screen coordinate {x, y}, get_pixel() 
  908.            returns the color of the pixel on the screen at that point. 
  909.            
  910.            When s is a 3-element sequence of the form: {x, y, n}
  911.            get_pixel() returns a sequence of n color values for the
  912.            points starting at {x,y} and moving to the right {x+1,y},
  913.            {x+2,y} etc.
  914.  
  915.            Points off the screen have unpredictable color values.
  916.  
  917.  Comments:    When n is specified, a very fast algorithm is used to read the
  918.            pixel colors on the screen. It is much faster to call pixel() 
  919.            once specifying a large value of n, than it is to call it many
  920.            times, reading one pixel color at a time.
  921.  
  922.  Example:     object x
  923.      
  924.            x = get_pixel({30,40})
  925.            -- x is set to the color value of point x=30, y=40
  926.            
  927.            x = get_pixel({30,40,100})
  928.            -- x is set to a sequence of 100 integer values, representing
  929.            -- the colors starting at {30,40} and going to the right
  930.  
  931.  See Also:    pixel, graphics_mode, get_position
  932.  
  933. ─────────────────────────────────<get_position>─────────────────────────────────
  934.  
  935.  Syntax:      include graphics.e
  936.            s = get_position()
  937.      
  938.  Description: Return the current line and column position of the cursor as a 
  939.            2-element sequence {line, column}.
  940.  
  941.  See Also:    position, get_pixel
  942.  
  943. ─────────────────────────────────────<getc>─────────────────────────────────────
  944.  
  945.  Syntax:      i = getc(fn)
  946.     
  947.  Description: Get the next character (byte) from file fn. -1 is returned at end 
  948.           of file.
  949.           
  950.  Comments:    File input using getc is buffered, i.e. getc does not actually 
  951.            go out to the disk for each character. Instead, a large block of 
  952.            characters will be read in at one time and returned to you one 
  953.            by one from a memory buffer.
  954.            
  955.  See Also:    gets, get_key, wait_key, open
  956.  
  957. ────────────────────────────────────<getenv>────────────────────────────────────
  958.  
  959.  Syntax:      x = getenv(s)
  960.     
  961.  Description: Return the value of a DOS environment variable. If the variable
  962.             is undefined return -1.
  963.     
  964.  Example:     e = getenv("EUDIR")
  965.           -- e will be "C:\EUPHORIA" -- or perhaps D:, E: etc.
  966.  
  967.  Comments:    Because either a sequence or an atom (-1) might be returned, you 
  968.            will probably want to assign the result to a variable declared 
  969.            as object.
  970.  
  971.  See Also:    command_line
  972.            
  973. ─────────────────────────────────────<gets>─────────────────────────────────────
  974.  
  975.  Syntax:      x = gets(fn)
  976.     
  977.  Description: Get the next sequence (one line, including \n) of characters 
  978.            from file fn. The atom -1 is returned on end of file. 
  979.           
  980.  Comments:    Because either a sequence or an atom (-1) might be returned, you 
  981.            will probably want to assign the result to a variable declared 
  982.            as object.
  983.  
  984.  Example:
  985.           sequence buffer
  986.           object line
  987.         
  988.           -- read a text file into a sequence
  989.           buffer = {}
  990.           while 1 do
  991.                line = gets(0)
  992.                if atom(line) then
  993.               exit   -- end of file
  994.                end if
  995.                buffer = append(buffer, line)
  996.           end while
  997.  
  998.  See Also:    getc, puts, open
  999.  
  1000. ────────────────────────────────<graphics_mode>─────────────────────────────────
  1001.  
  1002.  Syntax:      include graphics.e
  1003.            i1 = graphics_mode(i2)
  1004.     
  1005.  Description: Select graphics mode i2. See graphics.e for a list of valid 
  1006.           graphics modes. If successful, i1 is set to 0, otherwise i1
  1007.           is set to 1.
  1008.  
  1009.  Example:     if graphics_mode(18) then
  1010.                puts(SCREEN, "need VGA graphics!\n")
  1011.                  abort(1)
  1012.            end if
  1013.            draw_line(BLUE, {{0,0}, {50,50}})
  1014.  
  1015.  See Also:    text_rows, video_config
  1016.  
  1017. ─────────────────────────────────<int_to_bits>──────────────────────────────────
  1018.  
  1019.  Syntax:      include machine.e
  1020.            s = int_to_bits(a, i)
  1021.  
  1022.  Description: Returns the low-order i bits of a, as a sequence of 1's and 0's.
  1023.            The least significant bits come first. For negative numbers
  1024.            the two's complement bit pattern is returned.
  1025.            
  1026.  Comments:    You can use subscripting, slicing, and/or/not of entire 
  1027.            sequences etc. to manipulate sequences of bits. Shifting 
  1028.            of bits and rotating of bits are easy to perform.
  1029.  
  1030.  Example:     s = int_to_bits(177, 8)
  1031.            -- s is {1,0,0,0,1,1,0,1} -- "reverse" order
  1032.             
  1033.  See Also:    bits_to_int, and/or/not of entire sequences in refman.doc
  1034.  
  1035. ─────────────────────────────────<int_to_bytes>─────────────────────────────────
  1036.  
  1037.  Syntax:      include machine.e
  1038.            s = int_to_bytes(a)
  1039.     
  1040.  Description: Convert an integer into a sequence of 4 bytes. These bytes are in
  1041.           the order expected on the 386+, i.e. least significant byte 
  1042.           first.
  1043.     
  1044.  Comments:    You might use this routine prior to poking the 4 bytes into 
  1045.            memory for use by a machine language program.
  1046.      
  1047.           The integer can be negative. Negative byte-values will be
  1048.           returned, but after poking them into memory you will have 
  1049.           the correct (two's complement) representation for the 386+.
  1050.            
  1051.  Example 1:   s = int_to_bytes(999)
  1052.            -- s is {231, 3, 0, 0}
  1053.  
  1054.  Example 2:   s = int_to_bytes(-999)
  1055.            -- s is {-231, -4, -1, -1}
  1056.            
  1057.  See Also:    bytes_to_int, int_to_bits, bits_to_int, peek, poke
  1058.  
  1059. ───────────────────────────────────<integer>────────────────────────────────────
  1060.                   
  1061.  Syntax:      i = integer(x)
  1062.     
  1063.  Description: Return 1 if x is an integer in the range -1073741824 to 
  1064.            +1073741823. Otherwise return 0.  
  1065.  
  1066.  Comments:    This serves to define the integer type. You can also call it 
  1067.            like an ordinary function to determine if an object is an
  1068.            integer.
  1069.       
  1070.  Example 1:   integer z
  1071.            z = -1
  1072.            
  1073.  Example 2:   if integer(y/x) then
  1074.                puts(SCREEN, "y is an exact multiple of x")
  1075.            end if
  1076.  
  1077.  See Also:    atom, sequence, floor
  1078.  
  1079. ────────────────────────────────────<length>────────────────────────────────────
  1080.  
  1081.  Syntax:      i = length(s)
  1082.     
  1083.  Description: Return the length of s. s must be a sequence. An error will
  1084.            occur if s is an atom.
  1085.  
  1086.  Comments:    The length of each sequence is stored internally by the
  1087.            interpreter for quick access. (In other languages this
  1088.            operation requires a search through memory for an end marker.)
  1089.         
  1090.  Example 1:   length({{1,2}, {3,4}, {5,6}})   -- 3
  1091.  
  1092.  Example 2:   length("")    -- 0
  1093.  
  1094.  Example 3:   length({})    -- 0
  1095.  
  1096. ─────────────────────────────────────<log>──────────────────────────────────────
  1097.  
  1098.  Syntax:      x2 = log(x1)
  1099.     
  1100.  Description: Return the natural logarithm of x1.
  1101.  
  1102.  Comments:    This function may be applied to an atom or to all elements
  1103.            of a sequence. Note that log is only defined for positive
  1104.            numbers.
  1105.  
  1106.  Example:     a = log(100)
  1107.            -- a is 4.60517
  1108.  
  1109.  See Also:    sin, cos, tan, sqrt
  1110.  
  1111. ────────────────────────────────────<lower>─────────────────────────────────────
  1112.  
  1113.  Syntax:      include wildcard.e
  1114.            s2 = lower(s1)
  1115.  
  1116.  Description: Convert a string of characters to lower case.
  1117.  
  1118.  Example:     s = lower("Euphoria")
  1119.            -- s is "euphoria"
  1120.            
  1121.  See Also:    upper
  1122.  
  1123. ─────────────────────────────────<machine_func>─────────────────────────────────
  1124.  
  1125.  Syntax:      x = machine_func(a, x)
  1126.  
  1127.  Description: see machine_proc() below
  1128.  
  1129. ─────────────────────────────────<machine_proc>─────────────────────────────────
  1130.  
  1131.  Syntax:      machine_proc(a, x) 
  1132.     
  1133.  Description: Perform a machine-specific operation such as graphics and sound
  1134.             effects. This routine should normally be called indirectly via 
  1135.             one of the library routines in a Euphoria include file. A direct
  1136.             call can cause a machine exception if done incorrectly.
  1137.  
  1138.  Comments:    The only reason that you might want to call machine_proc or
  1139.            machine_func directly would be to increase the speed of your
  1140.            program slightly, by eliminating a layer of subroutine call
  1141.            overhead.
  1142.  
  1143.  See Also:    machine_func
  1144.  
  1145. ────────────────────────────────────<match>─────────────────────────────────────
  1146.  
  1147.  Syntax:      i = match(s1, s2)
  1148.  
  1149.  Description: Try to match s1 against some slice of s2. If successful, return 
  1150.           the element number of s2 where the (first) matching slice begins, 
  1151.           else return 0. 
  1152.           
  1153.  Example:     location = match("pho", "Euphoria")
  1154.           -- location is set to 3
  1155.  
  1156.  See Also:    find, compare, wildcard_match
  1157.  
  1158. ─────────────────────────────────<mouse_events>─────────────────────────────────
  1159.  
  1160.  Syntax:      include mouse.e
  1161.            mouse_events(i) 
  1162.     
  1163.  Description: Use this procedure to select the mouse events that you want 
  1164.           get_mouse() to report. By default, get_mouse() will report all
  1165.           events. mouse_events() can be called at various stages of the 
  1166.           execution of your program, as the need to detect events changes.
  1167.  
  1168.  Comments:    It is good practice to ignore events that you are not interested
  1169.               in, particularly the very frequent MOVE event, in order to reduce
  1170.               the chance that you will miss a significant event.
  1171.  
  1172.  Example:     mouse_events(LEFT_DOWN + LEFT_UP + RIGHT_DOWN) 
  1173.            -- will restrict get_mouse() to reporting the left button 
  1174.              being pressed down or released, and the right button 
  1175.              being pressed down. All other events will be ignored. 
  1176.  
  1177.  See Also:    get_mouse, mouse_pointer
  1178.  
  1179. ────────────────────────────────<mouse_pointer>─────────────────────────────────
  1180.  
  1181.  Syntax:      include mouse.e
  1182.            mouse_pointer(i)
  1183.     
  1184.  Description: If i is 0 hide the mouse pointer, otherwise turn on the mouse 
  1185.            pointer. Multiple calls to hide the pointer will require
  1186.           multiple calls to turn it back on. The first call to either 
  1187.           get_mouse() or mouse_events() above, will also turn the pointer
  1188.           on (once).
  1189.     
  1190.  Comments:    It may be necessary to hide the mouse pointer temporarily when
  1191.             you update the screen. 
  1192.  
  1193.  See Also:    get_mouse, mouse_events
  1194.  
  1195. ─────────────────────────────────────<open>─────────────────────────────────────
  1196.  
  1197.  Syntax:      fn = open(s1, s2)
  1198.     
  1199.  Description: Open a file or device, to get the file number. -1 is returned if
  1200.             the open fails. s1 is the path name of the file or device.  s2 is
  1201.             the mode in which the file is to be opened. Possible modes are:
  1202.           
  1203.           "r"  - open text file for reading
  1204.           "rb" - open binary file for reading
  1205.           "w"  - create text file for writing
  1206.           "wb" - create binary file for writing
  1207.           "u"  - open text file for update (reading and writing)
  1208.           "ub" - open binary file for update
  1209.           "a"  - open text file for appending
  1210.           "ab" - open binary file for appending
  1211.  
  1212.           Files opened for read or update must already exist. Files opened
  1213.           for write or append will be created if necessary. A file opened 
  1214.           for write will be set to 0 bytes. Output to a file opened for
  1215.           append will start at the end of file.
  1216.  
  1217.           Output to text files will have carriage-return characters 
  1218.           automatically added before linefeed characters. On input, these 
  1219.           carriage-return characters are removed. A control-Z character 
  1220.           (ASCII 26) will signal an immediate end of file. 
  1221.     
  1222.           I/O to binary files is not modified in any way. Any byte values 
  1223.           from 0 to 255 can be read or written.
  1224.  
  1225.           Some typical devices that you can open are:
  1226.           
  1227.           "CON"    the console (screen)
  1228.           "AUX"    the serial auxiliary port 
  1229.           "COM1"   serial port 1
  1230.           "COM2"   serial port 2
  1231.           "PRN"    the printer on the parallel port
  1232.           "NUL"    a non-existent device that accepts and discards output 
  1233.  
  1234.  Example:     integer file_num
  1235.            sequence first_line
  1236.            constant ERROR = 2
  1237.            
  1238.            file_num = open("myfile", "r")
  1239.           if file_num = -1 then           
  1240.                  puts(ERROR, "couldn't open myfile\n")
  1241.            else
  1242.                first_line = gets(file_num)
  1243.            end if
  1244.                  
  1245.  See Also:    close
  1246.  
  1247. ───────────────────────────────────<palette>────────────────────────────────────
  1248.  
  1249.  Syntax:      include graphics.e     
  1250.            x = palette(i, s)
  1251.     
  1252.  Description: Change the color for color number i to s, where s is a sequence 
  1253.            of color intensities: {red, green, blue}. Each value in s can be
  1254.            from 0 to 63. If successful, a 3-element sequence containing the 
  1255.           previous color for i will be returned, and all pixels on the 
  1256.           screen with value i will be set to the new color. If 
  1257.           unsuccessful, the atom -1 will be returned. 
  1258.  Example:     
  1259.            x = palette(0, {15, 40, 10})
  1260.            -- color number 0 (normally black) is changed to a shade 
  1261.               of mainly green. 
  1262.            
  1263.  See Also:    all_palette 
  1264.  
  1265. ─────────────────────────────────────<peek>─────────────────────────────────────
  1266.  
  1267.  Syntax:      i = peek(a)
  1268.     
  1269.  Description: Read a single byte value in the range 0 to 255 from machine 
  1270.            address a.
  1271.  
  1272.  Comment:     Addresses can sometimes be larger than the largest value of 
  1273.            type integer. Variables that hold an address should be declared
  1274.            as atoms.
  1275.  
  1276.  See Also:    poke, allocate, free, call
  1277.  
  1278. ────────────────────────────────────<pixel>─────────────────────────────────────
  1279.  
  1280.  Syntax:      include graphics.e
  1281.            pixel(x, s) 
  1282.     
  1283.  Description: Set one or more pixels starting at point s, where s is a 
  1284.            2-element screen coordinate {x, y}. If x is an atom, one pixel 
  1285.            will be set to the color indicated by x. If x is a sequence then
  1286.            a number of pixels will be set, starting at s and moving to the 
  1287.            right (increasing x value, same y value).
  1288.  
  1289.  Comments:    When x is a sequence, a very fast algorithm is used to put the
  1290.            pixels on the screen. It is much faster to call pixel() once
  1291.            with a sequence of pixel colors, than it is to call it many
  1292.            times, plotting one pixel color at a time.
  1293.            
  1294.  Example 1:   pixel(BLUE, {50, 60})
  1295.           -- the point {50,60} is set to the color BLUE    
  1296.  
  1297.  Example 2:   pixel({BLUE, GREEN, WHITE, RED}, {50,60})
  1298.            -- {50,60} set to BLUE
  1299.            -- {51,60} set to GREEN
  1300.            -- {52,60} set to WHITE
  1301.            -- {53,60} set to RED
  1302.  
  1303.  See Also:    get_pixel, graphics_mode
  1304.  
  1305. ─────────────────────────────────────<poke>─────────────────────────────────────
  1306.  
  1307.  Syntax:      poke(a, i)
  1308.  
  1309.  Description: Write a single byte value, i, to memory address a. The lower 
  1310.            8-bits of i are actually stored.
  1311.           
  1312.  Comments:    Writing to the screen memory with poke() can be much faster than 
  1313.            using puts() or printf(), but the programming is more difficult 
  1314.            and less portable. In most cases the speed is not needed. For 
  1315.            example, the Euphoria editor never uses poke().
  1316.  
  1317.  See Also:    peek, allocate, free, call
  1318.  
  1319. ───────────────────────────────────<polygon>────────────────────────────────────
  1320.  
  1321.  Syntax:      include graphics.e
  1322.            polygon(i1, i2, s)
  1323.     
  1324.  Description: Draw a polygon with 3 or more vertices given in s, using a 
  1325.            certain color i1. Fill the area if i2 is 1. Don't fill if i2 
  1326.            is 0. 
  1327.  
  1328.  Example:     polygon(GREEN, 1, {{100, 100}, {200, 200}, {900, 700}})
  1329.           -- makes a solid green triangle.
  1330.  
  1331.  See Also:    draw_line, ellipse
  1332.  
  1333. ───────────────────────────────────<position>───────────────────────────────────
  1334.  
  1335.  Syntax:      position(a1, a2)
  1336.     
  1337.  Description: Set the cursor to line a1, column a2, where the top left corner 
  1338.           is position(1,1). An error will occur if this location is off 
  1339.           the screen.
  1340.  
  1341.  Comments:    The coordinate system for text is different from the one for
  1342.            graphics. In graphics modes the top-left is (0,0) and the 
  1343.            first coordinate controls the horizontal location.
  1344.  
  1345.  Example:     position(2,1)
  1346.            -- the cursor moves to the beginning of the second line from 
  1347.               the top of the screen
  1348.  
  1349.  See Also:    get_position, puts, print, printf
  1350.  
  1351. ────────────────────────────────────<power>─────────────────────────────────────
  1352.  
  1353.  Syntax:      x3 = power(x1, x2)
  1354.  
  1355.  Description: Raise x1 to the power x2
  1356.  
  1357.  Comments:    Powers of 2 are calculated very efficiently.
  1358.  
  1359.  Example:     ? power({5, 4, 3.5}, {2, 1, -0.5})  
  1360.            -- {25, 4, 0.534522} is printed
  1361.  
  1362.  See Also:    log, sqrt
  1363.  
  1364. ───────────────────────────────────<prepend>────────────────────────────────────
  1365.  
  1366.  Syntax:      s2 = prepend(s1, x)
  1367.     
  1368.  Description: Prepend x to the start of sequence s1. The length of s2 will be 
  1369.           length(s1) + 1. 
  1370.           
  1371.  Comments:    If x is an atom this is the same as s2 = x & s1. If x is a 
  1372.            sequence it is definitely not the same. e.g.
  1373.     
  1374.          prepend({1,2,3}, {0,0})    
  1375.              -- {{0,0}, 1, 2, 3}
  1376.  
  1377.          {0,0} & {1,2,3}        
  1378.                 -- {0, 0, 1, 2, 3}
  1379.  
  1380.            The case where s1 and s2 are the same variable is handled
  1381.            very efficiently.
  1382.  
  1383.  Example:     s = {}
  1384.            for i = 1 to 10 do
  1385.            s = prepend(s, i)
  1386.             end for
  1387.             -- s is {10,9,8,7,6,5,4,3,2,1}
  1388.             
  1389.  See Also:    append, concatenation operator (&) in refman.doc           
  1390.  
  1391. ────────────────────────────────────<print>─────────────────────────────────────
  1392.  
  1393.  Syntax:      print(fn, x)
  1394.     
  1395.  Description: Print an object x with braces { , , , } to show the structure.
  1396.           
  1397.  Comment:     If you want to see a string of characters, rather than just the 
  1398.           ASCII codes, you need to use puts or printf. 
  1399.  
  1400.  Example:     print(1, "ABC")  -- output is:  {65, 66, 67}
  1401.            puts(1, "ABC")   -- output is:  ABC
  1402.  
  1403.  See Also:    ?, puts, printf, get
  1404.  
  1405. ────────────────────────────────────<printf>────────────────────────────────────
  1406.  
  1407.  Syntax:      printf(fn, st, x)
  1408.     
  1409.  Description: Print x using format string st. If x is an atom then a single 
  1410.           value will be printed. If x is a sequence, then formats from st 
  1411.           are applied to successive elements of x. Thus printf always takes 
  1412.           exactly 3 arguments. Only the length of the last argument, 
  1413.           containing the values to be printed, will vary. The basic formats 
  1414.           are: 
  1415.           %d - print an atom as a decimal integer
  1416.           %x - print an atom as a hexadecimal integer
  1417.           %o - print an atom as an octal integer
  1418.           %s - print a sequence as a string of characters
  1419.           %e - print an atom as a floating point number with exponential 
  1420.                  notation
  1421.           %f - print an atom as a floating-point number with a decimal
  1422.                point but no exponent
  1423.           %g - print an atom as a floating point number using either
  1424.              the %f or %e format, whichever seems more appropriate
  1425.           %% - print the '%' character itself
  1426.  
  1427.           Field widths can be added to the basic formats, e.g. %5d, or 
  1428.           %8.2f. The number before the decimal point is the minimum field
  1429.           width to be used. The number after the decimal point is the 
  1430.           precision to be used.
  1431.  
  1432.           If the field width is negative, e.g. %-5d then the value will be 
  1433.           left-justified within the field. Normally it will be right-
  1434.           justified. If the field width starts with a leading 0, e.g. %08d
  1435.           then leading zeros will be supplied to fill up the field. If the
  1436.           field width starts with a '+' e.g. %+7d then a plus sign will be
  1437.           printed for positive values. 
  1438.  
  1439.  Example 1:   rate = 7.875
  1440.           printf(myfile, "The interest rate is: %8.2f\n", rate)
  1441.           
  1442.           The interest rate is:     7.88
  1443.  
  1444.  Example 2:   name="John Smith"
  1445.           score=97
  1446.           printf(1, "%15s, %5d\n", {name, score})
  1447.  
  1448.                John Smith,    97
  1449.                
  1450.  Comments:    Watch out for the following common mistake:
  1451.  
  1452.              printf(1, "%15s", name)
  1453.  
  1454.           This will print only the first character of name, as each element 
  1455.           of name is taken to be a separate value to be formatted. You must 
  1456.           say this instead:
  1457.  
  1458.              printf(1, "%15s", {name})
  1459.  
  1460.  See Also:    sprintf, puts, open         
  1461.  
  1462. ─────────────────────────────────────<puts>─────────────────────────────────────
  1463.  
  1464.  Syntax:      puts(fn, x)
  1465.     
  1466.  Description: Output a single character (atom) or sequence of characters as 
  1467.            bytes of text.
  1468.  
  1469.  Example 1:   puts(SCREEN, "Enter your first name: ")
  1470.  
  1471.  Example 2:   puts(output, 'A')  -- the single byte 65 will be sent to output  
  1472.  
  1473.  See Also:    printf, gets, open
  1474.  
  1475. ─────────────────────────────────────<rand>─────────────────────────────────────
  1476.  
  1477.  Syntax:      x2 = rand(x1) 
  1478.     
  1479.  Description: Return a random integer from 1 to x1, where x1 may be from 1 to 
  1480.           the largest positive value of type integer (1073741823).
  1481.  
  1482.  Comments:    This function may be applied to an atom or to all elements
  1483.            of a sequence.
  1484.  
  1485.  Example:     s = rand({10, 20, 30})
  1486.            -- s might be: {5, 17, 23} or {9, 3, 12} etc.
  1487.            
  1488. ─────────────────────────────────<read_bitmap>──────────────────────────────────
  1489.  
  1490.  Syntax:      include image.e
  1491.            x = read_bitmap(st)
  1492.  
  1493.  Description: st is the name of a .bmp "bitmap" file. The file should be in
  1494.            the bitmap format. The most common variations of the format
  1495.            are supported. If the file is read successfully the result will
  1496.            be a 2-element sequence. The first element is the palette. The
  1497.            second element is a 2-d sequence of sequences containing a 
  1498.            graphics-mode image. You can pass the palette to all_palette() 
  1499.            (after dividing it by 4 to scale it). The image can be passed 
  1500.            to display_image().
  1501.           
  1502.           Bitmaps of 2,4,16 or 256 colors are supported. If the file is 
  1503.           not in a good format an error code (atom) is returned instead:
  1504.           
  1505.         global constant BMP_OPEN_FAILED = 1,
  1506.                 BMP_UNEXPECTED_EOF = 2,
  1507.                 BMP_UNSUPPORTED_FORMAT = 3
  1508.           
  1509.  Comments:    You can create your own bitmap picture files using the Windows
  1510.            Paintbrush program. You can then incorporate these pictures 
  1511.            into your programs.
  1512.  
  1513.  Example:     x = read_bitmap("c:\\windows\\arcade.bmp")
  1514.            -- note: double backslash needed to get single backslash in
  1515.                       a string
  1516.  
  1517.  Example Program: demo\bitmap.ex
  1518.  
  1519.  See Also:    palette, display_image
  1520.  
  1521. ──────────────────────────────────<remainder>───────────────────────────────────
  1522.  
  1523.  Syntax:      x3 = remainder(x1, x2)
  1524.     
  1525.  Description: Compute the remainder after dividing x1 by x2. The result will 
  1526.            have the same sign as x1, and the magnitude of the result will
  1527.            be less than the magnitude of x2.
  1528.  
  1529.  Example 1:   s = remainder({81, -3.5, -9, 5.5}, {8, -1.7, 2, -4})
  1530.           -- s is {1, -0.1, -1, 1.5}
  1531.  
  1532.  Example 2:   s = remainder({17, 12, 34}, 16)
  1533.            -- s is {1, 12, 2}
  1534.  
  1535. ────────────────────────────────────<repeat>────────────────────────────────────
  1536.  
  1537.  Syntax:      s = repeat(x, a)
  1538.     
  1539.  Description: Create a sequence of length a where each element is x.
  1540.     
  1541.  Comments:    When you repeat a sequence or a floating-point number the
  1542.            interpreter does not actually make multiple copies in memory.
  1543.            Rather, a single copy is "pointed to" a number of times. 
  1544.            
  1545.  Example 1:   repeat(0, 10)      -- {0,0,0,0,0,0,0,0,0,0}
  1546.         
  1547.  Example 2:   repeat("JOHN", 4)  -- {"JOHN", "JOHN", "JOHN", "JOHN"}
  1548.  
  1549.  See Also:    append, prepend
  1550.  
  1551. ──────────────────────────────────<save_image>──────────────────────────────────
  1552.  
  1553.  Syntax:      include image.e
  1554.            s3 = save_image(s1, s2)
  1555.  
  1556.  Description: Save a rectangular image from a graphics screen. The result
  1557.            is a 2-d sequence of sequences containing all the pixels
  1558.            in the image. You can redisplay the image using display_image().
  1559.            s1 is a 2-element sequence {x1, y1} specifying the top-left 
  1560.            pixel in the image. s2 is a sequence {x2, y2} specifying the 
  1561.            bottom-right pixel.
  1562.  
  1563.  Comments:    You might use this in a graphical user interface to save a
  1564.            portion of the screen before you display a drop-down menu
  1565.            or dialog box.
  1566.            
  1567.  Example:     s = save_image({0,0}, {50,50})
  1568.            display_image({100,200}, s)
  1569.            display_image({300,400}, s)
  1570.            -- saves a 51x51 square image, then redisplays it at {100,200}
  1571.           -- and at {300,400}
  1572.  
  1573.  See Also:    display_image, save_text_image
  1574.  
  1575. ───────────────────────────────<save_text_image>────────────────────────────────
  1576.  
  1577.  Syntax:      include image.e
  1578.            s3 = save_text_image(s1, s2)
  1579.  
  1580.  Description: Save a rectangular region of text from a text-mode screen.
  1581.            The result is a sequence of sequences containing ASCII characters
  1582.            and attributes from the screen. You can redisplay this text using 
  1583.            display_text_image(). s1 is a 2-element sequence {line1, column1}
  1584.            specifying the top-left character. s2 is a sequence 
  1585.            {line2, column2} specifying the bottom right character.
  1586.            
  1587.  Comments:    Because the character attributes are also saved, you will get 
  1588.             the correct foreground and background color for each character
  1589.             if you redisplay the text.
  1590.             
  1591.           This routine only works in text modes.
  1592.           
  1593.            You might use this function in a text-mode graphical user 
  1594.            interface to save a portion of the screen before displaying a 
  1595.            drop-down menu, dialog box, alert box etc.
  1596.  
  1597.            If you are flipping video pages, note that this function reads
  1598.            from the current active page.
  1599.            
  1600.  Example:     If the top 2 lines of the screen have: 
  1601.           Hello 
  1602.           World
  1603.            
  1604.            s = save_text_image({1,1,}, {2, 5})
  1605.            
  1606.            Then s is something like: 
  1607.                    {"H-e-l-l-o-",
  1608.                           W-o-r-l-d-"}
  1609.            where we have indicated the attribute bytes by '-'
  1610.                
  1611.  See Also:    display_text_image, save_image, set_active_page
  1612.  
  1613. ────────────────────────────────────<scroll>────────────────────────────────────
  1614.  
  1615.  Syntax:      include graphics.e 
  1616.            scroll(i1, i2, i3)
  1617.  
  1618.  Description: Scroll a region of text on the screen either up (i1 positive) or
  1619.             down (i1 negative) by i1 lines. The region is the series of lines
  1620.           on the screen from i2 (top line) to i3 (bottom line), inclusive.
  1621.           A    new blank line will appear at the top or bottom.
  1622.  
  1623.  Example Program: see bin\ed.ex
  1624.  
  1625.  See Also:    clear_screen, text_rows
  1626.  
  1627. ─────────────────────────────────────<seek>─────────────────────────────────────
  1628.  
  1629.  Syntax:      include file.e
  1630.            i1 = seek(fn, i2)
  1631.  
  1632.  Description: Seek (move) to any byte position in the file fn or to the end of
  1633.             file if i2 is -1. For each open file there is a current byte 
  1634.             position that is updated as a result of I/O operations on the 
  1635.             file. The initial file position is 0 for files opened for read,
  1636.             write or update. The initial position is the end of file for 
  1637.             files opened for append. The value returned by seek() is 0 if the
  1638.             seek was successful, and non-zero if it was unsuccessful. It is 
  1639.             possible to seek past the    end of a file. In this case undefined 
  1640.             bytes will be added to the file to make it long enough for the 
  1641.             seek.
  1642.  
  1643.  See Also:    where, open
  1644.      
  1645. ───────────────────────────────<set_active_page>────────────────────────────────
  1646.            
  1647.  Syntax:      include image.e
  1648.            set_active_page(i)
  1649.            
  1650.  Description: Select video page i to send all screen output to.           
  1651.  
  1652.  Comments:    With multiple pages you can instantaneously change the entire
  1653.            screen without causing any visible "flicker". You can also
  1654.            save the screen and bring it back quickly.
  1655.  
  1656.           video_config() will tell you how many pages are available in
  1657.           the current graphics mode.
  1658.  
  1659.            By default, the active page and the display page are both 0.
  1660.            
  1661.            This works under DOS, or full-screen under Windows. In a 
  1662.            partial-screen window you cannot change the active page.
  1663.            
  1664.  Example:     include image.e
  1665.            
  1666.            -- active & display pages are initially both 0
  1667.            puts(1, "\nThis is page 0\n")
  1668.            set_active_page(1)     -- screen output will now go to page 1
  1669.            clear_screen()
  1670.            puts(1, "\nNow we've flipped to page 1\n")
  1671.            if getc(0) then        -- wait for key-press
  1672.            end if
  1673.            set_display_page(1)    -- "Now we've ..." becomes visible
  1674.            if getc(0) then        -- wait for key-press
  1675.            end if
  1676.           set_display_page(0)    -- "This is ..." becomes visible again
  1677.           set_active_page(0)
  1678.  
  1679.  See Also:    get_active_page, set_display_page 
  1680.  
  1681. ──────────────────────────────<set_display_page>────────────────────────────────
  1682.            
  1683.  Syntax:      include image.e
  1684.            set_display_page(i)
  1685.  
  1686.  Description: Set video page i to be mapped to the visible screen.
  1687.  
  1688.  Comments:    With multiple pages you can instantaneously change the entire
  1689.            screen without causing any visible "flicker". You can also
  1690.            save the screen and bring it back quickly.
  1691.  
  1692.           video_config() will tell you how many pages are available in
  1693.           the current graphics mode.
  1694.  
  1695.            By default, the active page and the display page are both 0.
  1696.            
  1697.            This works under DOS, or full-screen under Windows. In a 
  1698.            partial-screen window you cannot change the active page.
  1699.            
  1700.  Example:     See set_active_page example.
  1701.  
  1702.  See Also:    get_display_page, set_active_page
  1703.            
  1704. ───────────────────────────────────<sequence>───────────────────────────────────
  1705.  
  1706.  Syntax:      i = sequence(x)
  1707.     
  1708.  Description: Return 1 if x is a sequence else return 0.
  1709.  
  1710.  Comments:    This serves to define the sequence type. You can also call
  1711.            it like an ordinary function to determine if an object is
  1712.            a sequence.
  1713.  
  1714.  Example 1:
  1715.            sequence s
  1716.            s = {1,2,3}
  1717.        
  1718.  Example 2:
  1719.            if sequence(x) then
  1720.                  sum = 0
  1721.                  for i = 1 to length(x) do
  1722.                      sum = sum + x[i]
  1723.                  end for
  1724.            else
  1725.                -- x must be an atom
  1726.                sum = x     
  1727.            end if
  1728.  
  1729.  See Also:    atom, object type in refman.doc
  1730.  
  1731. ─────────────────────────────────────<sin>──────────────────────────────────────
  1732.  
  1733.  Syntax:      x2 = sin(x1)
  1734.     
  1735.  Description: Return the sine of x1, where x1 is in radians.
  1736.  
  1737.  Comments:    This function may be applied to an atom or to all elements
  1738.            of a sequence.
  1739.  
  1740.  Example:     sin_x = sin({.5, .9, .11})
  1741.            -- sin_x is {.479, .783, .110} 
  1742.  
  1743.  See Also:    cos, tan
  1744.  
  1745. ─────────────────────────────────────<sort>─────────────────────────────────────
  1746.  
  1747.  Syntax:      include sort.e
  1748.            x2 = sort(x1)
  1749.     
  1750.  Description: Sort x into ascending order using a fast sorting algorithm. By 
  1751.           defining your own compare function to override the built-in 
  1752.           compare(), you can change the ordering of values from sort(), and 
  1753.           perhaps choose a field or element number on which to base the 
  1754.           sort. Define your compare() as a global function before 
  1755.           including sort.e.
  1756.  
  1757.  Example:     x = 0 & sort({7,5,3,8}) & 0
  1758.           -- x is set to {0, 3, 5, 7, 8, 0}
  1759.  
  1760.  See Also:    compare, match, find
  1761.   
  1762. ────────────────────────────────────<sound>─────────────────────────────────────
  1763.  
  1764.  Syntax:      sound(i)
  1765.     
  1766.  Description: Turn on the PC speaker at frequency i. If i is 0 the speaker 
  1767.            will be turned off.
  1768.  
  1769.  Example:     sound(1000) -- starts a fairly high pitched sound
  1770.  
  1771. ───────────────────────────────────<sprintf>────────────────────────────────────
  1772.  
  1773.  Syntax:      s = sprintf(st, x)
  1774.  
  1775.  Description: This is exactly the same as printf(), except that the output
  1776.            is returned as a sequence of characters, rather than being
  1777.            sent to a file or device. st is a format string, x is the
  1778.            value or sequence of values to be formatted. printf(fn, st, x) 
  1779.            is equivalent to puts(fn, sprintf(st, x)).
  1780.  
  1781.  Comments:    Some typical uses of sprintf are:
  1782.                 
  1783.                 1. Converting numbers to strings.
  1784.                 2. Creating strings to pass to system().
  1785.                 3. Creating formatted error messages and passing them to
  1786.                    a common error message handler.
  1787.  
  1788.  Example:     s = sprintf("%08d", 12345)
  1789.             -- s is "00012345"
  1790.             
  1791.  See Also:    printf, value, get
  1792.  
  1793. ─────────────────────────────────────<sqrt>─────────────────────────────────────
  1794.  
  1795.  Syntax:      x2 = sqrt(x1)   
  1796.     
  1797.  Description: Calculate the square root of x1.
  1798.  
  1799.  Comments:    This function may be applied to an atom or to all elements
  1800.            of a sequence.
  1801.  
  1802.  Example:     r = sqrt(16)
  1803.            -- r is 4
  1804.  
  1805.  See Also:    log, power
  1806.  
  1807. ────────────────────────────────────<system>────────────────────────────────────
  1808.  
  1809.  Syntax:      system(s, a)
  1810.     
  1811.  Description: Pass a command string s to the DOS command interpreter for 
  1812.            execution. The argument a indicates the manner in which to 
  1813.           return from the system call. 
  1814.         
  1815.         value of a      return action
  1816.         ----------    ------------- 
  1817.              0      - restore previous graphics mode
  1818.                   (clears the screen)
  1819.              1      - make a beep sound, wait for a
  1820.                   key press, then restore the
  1821.                   graphics mode
  1822.              2      - do not restore graphics mode
  1823.  
  1824.  Comments:    Action 2 should only be used when it is known that the system 
  1825.            call will not change the graphics mode. 
  1826.  
  1827.           You can use Euphoria as a sophisticated DOS "batch" language
  1828.           by making calls to system().
  1829.           
  1830.  Example:     system("copy temp.txt a:\\temp.bak", 2)
  1831.            -- note use of double backslash in literal string to get 
  1832.               single backslash
  1833.  
  1834.  Example Program: see install.ex
  1835.  
  1836.  See Also:    dir, current_dir, getenv, command_line
  1837.  
  1838. ─────────────────────────────────────<tan>──────────────────────────────────────
  1839.  
  1840.  Syntax:      x2 = tan(x1) 
  1841.     
  1842.  Description: Return the tangent of x1, where x1 is in radians.
  1843.  
  1844.  Comments:    This function may be applied to an atom or to all elements
  1845.            of a sequence.
  1846.  
  1847.  Example:     t = tan(1.0)
  1848.            -- t is 1.55741
  1849.          
  1850.  See Also:    sin, cos
  1851.  
  1852. ──────────────────────────────────<text_color>──────────────────────────────────
  1853.  
  1854.  Syntax:      include graphics.e
  1855.            text_color(i)
  1856.     
  1857.  Description: Set the foreground text color. Add 16 to get blinking text
  1858.           in some modes. See graphics.e for a list of possible colors.
  1859.  
  1860.  Example:     text_color(BRIGHT_BLUE)
  1861.  
  1862.  See Also:    bk_color
  1863.  
  1864. ──────────────────────────────────<text_rows>───────────────────────────────────
  1865.  
  1866.  Syntax:      include graphics.e
  1867.            i2 = text_rows(i1)
  1868.     
  1869.  Description: Set the number of lines of text on the screen to i1 if possible.
  1870.           i2 will be set to the actual new number of lines.
  1871.  
  1872.  Comments:    Values of 25, 28, 43 and 50 lines are supported by most graphics
  1873.            cards.
  1874.            
  1875.  See Also:    graphics_mode
  1876.  
  1877. ─────────────────────────────────────<time>─────────────────────────────────────
  1878.  
  1879.  Syntax:      a = time()
  1880.     
  1881.  Description: Return the number of seconds since some fixed point in the past.
  1882.             The resolution on MS-DOS is about 0.05 seconds. 
  1883.  
  1884.  Comments:    Take the difference between two readings of time(), to
  1885.            measure, for example, how long a section of code takes to
  1886.            execute.
  1887.  
  1888.  Example:     constant ITERATIONS = 1000000 
  1889.            integer p
  1890.            atom t0, loop_overhead
  1891.            
  1892.            t0 = time()
  1893.            for i = 1 to ITERATIONS do
  1894.            end for
  1895.            loop_overhead = time() - t0
  1896.      
  1897.           t0 = time()
  1898.            for i = 1 to ITERATIONS do
  1899.                  p = power(2, 20)
  1900.            end for
  1901.            ? (time() - t0 - loop_overhead)/ITERATIONS
  1902.            -- calculates time (in seconds) for one call to power
  1903.            
  1904.  See Also:    date
  1905.  
  1906. ────────────────────────────────────<trace>─────────────────────────────────────
  1907.  
  1908.  Syntax:      with trace
  1909.            trace(x) 
  1910.     
  1911.  Description: If x is 1 or 2 then turn on full-screen statement tracing. If x 
  1912.            is 0 then    turn off tracing. When x is 2 a monochrome trace 
  1913.            display is forced on. Tracing only occurs in subroutines that 
  1914.            were compiled "with trace". See the section on Debugging in
  1915.            refman.doc.
  1916.  
  1917.  Comments:    Use trace(2) if the color display is hard to view on your system.
  1918.  
  1919.  Example:     if x < 0 then
  1920.            -- ok, here's the case I want to debug...
  1921.            trace(1)
  1922.            -- etc.
  1923.           ...
  1924.           end if           
  1925.                
  1926.  See Also:    Chapter 3 in refman.doc.
  1927.  
  1928. ────────────────────────────────────<upper>─────────────────────────────────────
  1929.  
  1930.  Syntax:      include wildcard.e
  1931.            s2 = upper(s1)
  1932.  
  1933.  Description: Convert a string of characters to upper case.
  1934.  
  1935.  Example:     s = upper("Euphoria")
  1936.            -- s is "EUPHORIA"
  1937.            
  1938.  See Also:    lower
  1939.  
  1940. ────────────────────────────────────<value>─────────────────────────────────────
  1941.  
  1942.  Syntax:      include get.e
  1943.            s = value(st)
  1944.  
  1945.  Description: Read the string representation of a Euphoria object, and compute
  1946.            the value of that object. A 2-element sequence, 
  1947.            {error_status, value} is actually returned, where error_status
  1948.            can be one of:
  1949.         
  1950.         GET_SUCCESS     -- a valid object representation was found
  1951.         GET_EOF        -- end of string reached too soon
  1952.         GET_FAIL    -- syntax is wrong 
  1953.                
  1954.  Comments:    This works the same as get(), but it reads from a string
  1955.            that you supply, rather than from a file or device.
  1956.            
  1957.  Example 1:   s = value("12345"}
  1958.            -- s is {GET_SUCCESS, 12345}
  1959.            
  1960.  Example 2:   s = value("{0, 1, -99.9}")
  1961.            -- s is {GET_SUCCESS, {0, 1, -99.9}}
  1962.            
  1963.  Example 3:   s = value("+++")
  1964.            -- s is {GET_FAIL, 0}
  1965.  
  1966.  See Also:    get, sprintf, print
  1967.  
  1968. ─────────────────────────────────<video_config>─────────────────────────────────
  1969.  
  1970.  Syntax:      include graphics.e
  1971.            s = video_config()
  1972.     
  1973.  Description: Return a sequence of values describing the current video
  1974.           configuration:
  1975.         {color monitor?, graphics mode, text rows, text columns,
  1976.          xpixels, ypixels, number of colors, number of pages}
  1977.            
  1978.            The following constants are defined in graphics.e:
  1979.             
  1980.             global constant VC_COLOR = 1,
  1981.                 VC_MODE  = 2,
  1982.                 VC_LINES = 3,
  1983.                 VC_COLUMNS = 4,
  1984.                 VC_XPIXELS = 5,
  1985.                 VC_YPIXELS = 6,
  1986.                 VC_NCOLORS = 7,
  1987.                 VC_PAGES = 8
  1988.            
  1989.  Comments:    This routine makes it easy for you to parameterize a program 
  1990.            so it will work in many different graphics modes.
  1991.            
  1992.  Example:     vc = video_config()  -- in mode 3 with 25-lines of text:
  1993.            -- vc is {1, 3, 25, 80, 0, 0, 32, 8}
  1994.  
  1995. ──────────────────────────────────<wait_key>────────────────────────────────────
  1996.  
  1997.  Syntax:      include get.e
  1998.            i = wait_key()
  1999.            
  2000.  Description: Return the next key pressed by the user. Don't return until
  2001.             a key is pressed.
  2002.             
  2003.  Comments:    You could achieve the same result using get_key() as follows:
  2004.                 
  2005.                 while 1 do
  2006.                     k = get_key()
  2007.                     if k != -1 then
  2008.                         exit
  2009.                     end if
  2010.                 end while    
  2011.  
  2012.            However, on multi-tasking systems like Windows, Windows NT,
  2013.            or OS/2 this "busy waiting" would slow the system down. 
  2014.            wait_key() lets the operating system do other useful work 
  2015.            while your program is waiting for the user to press a key.
  2016.  
  2017.            You could also use getc(0), assuming file number 0 was input 
  2018.            from the keyboard, except that you wouldn't pick up the special
  2019.            codes for function keys, arrow keys etc.
  2020.            
  2021.  See Also:    get_key, getc
  2022.  
  2023. ────────────────────────────────────<where>─────────────────────────────────────
  2024.  
  2025.  Syntax:      include file.e
  2026.            i = where(fn)
  2027.     
  2028.  Description: This function returns the current byte position in the file fn.
  2029.           This position is updated by reads, writes and seeks on the file.
  2030.           It is the place in the file where the next byte will be read 
  2031.           from, or written to.
  2032.  
  2033.  See Also:    seek, open
  2034.  
  2035. ────────────────────────────────<wildcard_file>─────────────────────────────────
  2036.  
  2037.  Syntax:      include wildcard.e
  2038.            i = wildcard_file(s1, s2)
  2039.  
  2040.  Description: Return 1 (TRUE) if the filename s2 matches the wild card pattern
  2041.            s1. Return 0 (FALSE) otherwise. This is similar to DOS wildcard
  2042.            matching, but better in some cases. * matches any 0 or more 
  2043.            characters, ? matches any single character. Character comparisons
  2044.            are not case sensitive. 
  2045.  
  2046.  Comments:    You might use this function to check the output of the dir()
  2047.            routine for file names that match a pattern supplied by the 
  2048.            user of your program.
  2049.  
  2050.            In DOS "*ABC.*" will match ALL files. wildcard_file("*ABC.*", s)
  2051.            will only match when the file name part has "ABC" at the end
  2052.            (as you would expect).
  2053.  
  2054.  Example 1:   i = wildcard_file("AB*CD.?", "aB123cD.e")  
  2055.           -- i is set to 1
  2056.           
  2057.  Example 2:   i = wildcard_file("AB*CD.?", "abcd.ex")
  2058.            -- i is set to 0, because the file type has 2 letters not 1
  2059.            
  2060.  Example Program: see bin\search.ex
  2061.  
  2062.  See Also:    wildcard_match, dir
  2063.  
  2064. ────────────────────────────────<wildcard_match>────────────────────────────────
  2065.  
  2066.  Syntax:      include wildcard.e
  2067.            i = wildcard_match(s1, s2)
  2068.  
  2069.  Description: This function performs general matching of a string against a 
  2070.            pattern containing * and ? wildcards. It returns 1 (TRUE) if 
  2071.            string s2 matches pattern s1. It returns 0 (FALSE) otherwise. 
  2072.            * matches any 0 or more characters. ? matches any
  2073.            single character. Character comparisons are case sensitive.
  2074.  
  2075.  Comments:    If you want case insensitive comparisons, pass both s1 and s2
  2076.            through upper(), or both through lower() before calling
  2077.            wildcard_match().
  2078.  
  2079.            If you want to detect a pattern anywhere within a string,
  2080.            add * to each end of the pattern:
  2081.              
  2082.              i = wildcard_match('*' & pattern & '*', string)
  2083.  
  2084.            There is currently no way to treat * or ? literally in a pattern.
  2085.            
  2086.  Example 1:   i = wildcard_match("A?B*", "AQBXXYY")          
  2087.            -- i is 1 (TRUE)
  2088.            
  2089.  Example 2:   i = wildcard_match("*xyz*", "AAAbbbxyz")
  2090.            -- i is 1 (TRUE)
  2091.  
  2092.  Example 3:   i = wildcard_match("A*B*C", "a111b222c")
  2093.            -- i is 0 (FALSE) because upper/lower case doesn't match
  2094.  
  2095.  Example Program: see bin\search.ex
  2096.  
  2097.  See Also:    wildcard_file, match, upper, lower, compare
  2098.  
  2099. ─────────────────────────────────────<wrap>─────────────────────────────────────
  2100.  
  2101.  Syntax:      include graphics.e
  2102.            wrap(i)
  2103.     
  2104.  Description: Allow text to wrap at the right margin (i = 1) or get truncated
  2105.             (i = 0).
  2106.  
  2107.  Comments:    By default text will wrap.
  2108.  
  2109.  Example:     puts(1, repeat('x', 100) & "\n\n") 
  2110.            -- now have a line of 80 'x' followed a line of 20 more 'x'
  2111.            wrap(0)
  2112.            puts(1, repeat('x', 100) & "\n\n")
  2113.            -- creates just one line of 80 'x' 
  2114.            
  2115.  See Also:    puts, position
  2116.  
  2117.